package com.ymatou.iapi.coupon.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;
/**
*获取用户即将过期的优惠券面额Call
*FreeMaker Template自动生成代码
*/
public class getUserExpiringAmountCall extends YmatouBaseCall{
	private static String opurl ="api/Promotion/getUserExpiringAmount";
	
	public getUserExpiringAmountCall() {
		super(EnvSetup.getSystemUrl("couponiapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		return getString("statusCode");		
	}

	/**
	 * 获取Message
	 * 
	 * @return
	 */
	public String getMessage() {
		return getString("message");	
	}
	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public String getData() {
		return getString("data");	
	}
	
	public int getDataErrorCode() {
		int result = 0;
		try {
			result = new JSONObject(getData()).getInt("errorCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	
	public String getDataErrorMessage() {
		String result = null;
		try {
			result = new JSONObject(getData()).getString("errorMessage");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	
	public String getAmount() {
		String result = null;
		try {
			result = new JSONObject(getData()).getString("amount");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
}